<?php

class BIS_Form_Element_Period extends Zend_Form_Element {
	
	public $helper = "periodElement";
	
	protected $month = null;
	protected $year = null;
	
	function setMonth($month) {
		$this->month = $month;
		return $this;
	}
	
	function setYear($year) {
		$this->year = $year;
		return $this;
	}
	
	public function setValue($value) {
		if (is_array ( $value ) && (isset ( $value ['month'] )) && (isset ( $value ['year'] ))) {
			$this->setMonth ( $value ['month'] )->setYear ( $value ['year'] );
		} elseif (! empty ( $value )) {
			list ( $this->month, $this->year ) = split ( '-', $value );
		}
	}
	
	public function getValue() {
		if (! $this->month || ! $this->year)
			return false;
		return $this->month . '-' . $this->year;
	}
}

